package com.medata.service.impl;

import com.medata.dataObject.UserCollections;
import com.medata.repository.UserCollectionsRepository;
import com.medata.service.UserCollectionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author ：zb
 * @date ：Created in 2019/7/23 0023 17:09
 * @description：
 */
@Service
public class UserCollectionsServiceImpl implements UserCollectionsService {
    @Autowired
    private UserCollectionsRepository repository;

    @Override
    @Transactional
    public void deleteById(Integer id) {
        repository.deleteById(id);
    }

    @Override
    public void saveOrUpdate(UserCollections collections) {
        repository.save(collections);
    }

    @Override
    public Page<UserCollections> findByUserName(String userName, Pageable pageable) {
        return repository.findByUserName(userName,pageable);
    }

    @Override
    public List<UserCollections> findAllByUserName(String userName) {
        return repository.findAllByUserName(userName);
    }

    @Override
    public UserCollections findByUserNameAndWordAndWordId(String username, String word, Integer wordId) {
        return repository.findByUserNameAndWordAndWordId(username,word,wordId);
    }

    @Override
    public List<UserCollections> findByUserNameAndWord(String userName, String word) {
        return repository.findByUserNameAndWord(userName,word);
    }
}
